package com.example.travel_front.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.travel_front.Adapter.CommentAdapter;
import com.example.travel_front.Model.Comment;
import com.example.travel_front.R;

import java.util.ArrayList;
import java.util.List;

public class CaregiverDetailActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.caregiver_detail);
        // Initialize RecyclerView and Adapter
        RecyclerView commentsRecyclerView = findViewById(R.id.commentsRecyclerView); // Replace with your RecyclerView ID
        CommentAdapter commentAdapter = new CommentAdapter(getCommentsData()); // Assume getCommentsData() returns a List<Comment>
        commentsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        commentsRecyclerView.setAdapter(commentAdapter);
        // 获取传递的数据
        if (getIntent().hasExtra("key")) {
            String data = getIntent().getStringExtra("key");
            // 使用数据进行操作，比如更新UI
        }
        ImageView locationIcon = findViewById(R.id.location_icon);
        locationIcon.setOnClickListener(v -> {
            // Create an intent to start the new Activity
            Intent intent = new Intent(CaregiverDetailActivity.this, DiscoverActivity.class); // Replace NewActivity.class with the name of your new Activity
            startActivity(intent);
        });

    }
    private List<Comment> getCommentsData() {
        // TODO: Implement this method to return actual comment data
        List<Comment> topics = new ArrayList<>();

        topics.add(new Comment("John Doe", "https://jdhn.oss-cn-hangzhou.aliyuncs.com/avatar1.png", "Can anyone recommend iconic spots in New York for photography?", 240, 12, "30 minutes ago"));
        topics.add(new Comment("Alice Johnson", "https://jdhn.oss-cn-hangzhou.aliyuncs.com/avatar2.png", "Looking for hidden gems in New York, any local favorites?", 112, 7, "1 hour ago"));
        topics.add(new Comment("Mark Smith", "https://jdhn.oss-cn-hangzhou.aliyuncs.com/avatar3.png", "What's the best way to spend a day in Central Park?", 340, 15, "2 hours ago"));
        topics.add(new Comment("Emily Davis", "https://jdhn.oss-cn-hangzhou.aliyuncs.com/avatar4.png", "Is the Statue of Liberty worth the visit? Any tips for a first-timer?", 621, 5, "3 hours ago"));

        return topics;

    }
}
